//
// Decompiled with: Decompiler.NET, Version=1.3.1.18439, Culture=neutral, PublicKeyToken=null, Version: 1.3.1.18439
// Decompilation Started at: 3/15/2009 10:34:26 PM
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. 
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace PatientManagement

{
		
		#region Namespace Import Declarations
		
			using Microsoft.Win32;
			using System;
			using System.Windows.Forms;
			
		#endregion
		
	public class ModifyRegistry
	
	{
		
		#region Fields
			private RegistryKey baseRegistryKey;
			private bool showError;
			private string subKey;
		#endregion
		
		#region Constructors
		
			public ModifyRegistry ()
			
			{
				this.showError = false;
				this.subKey = "SOFTWARE\\PatientManagement\\Product\\Pm\\Patient";
				this.baseRegistryKey = Registry.LocalMachine;
				return;
			}
			
		#endregion
		
		#region Properties
		
			public RegistryKey BaseRegistryKey
			
			{
				get
				{
					RegistryKey theRegistryKey;
					theRegistryKey = this.baseRegistryKey;
					goto L_0009;
					
				L_0009:
					
					{
					}
					return theRegistryKey;
				}
				set
				{
					this.baseRegistryKey = value;
					return;
				}
			}
			
			
			public bool ShowError
			
			{
				get
				{
					bool theBoolean;
					theBoolean = this.showError;
					goto L_0009;
					
				L_0009:
					
					{
					}
					return theBoolean;
				}
				set
				{
					this.showError = value;
					return;
				}
			}
			
			
			public string SubKey
			
			{
				get
				{
					string theString;
					theString = this.subKey;
					goto L_0009;
					
				L_0009:
					
					{
					}
					return theString;
				}
				set
				{
					this.subKey = value;
					return;
				}
			}
			
		#endregion
		
		#region Methods
		
			public bool DeleteKey (string KeyName)
			
			{
				RegistryKey theRegistryKey;
				RegistryKey theRegistryKey2;
				Exception theException;
				bool theBoolean;
				
			L_0000:
				try
				{
					theRegistryKey = this.baseRegistryKey;
					theRegistryKey2 = theRegistryKey.CreateSubKey (this.subKey);
					if (theRegistryKey2 != null)
					{
						goto L_001B;
					}
					theBoolean = true;
					goto L_0042;
					
				L_001B:
					
					{
					}
					theRegistryKey2.DeleteValue (KeyName);
					theBoolean = true;
				}
				catch (Exception theException2)
				{
					
				L_0026:
					theException = theException2;
					this.ShowErrorMessage (theException, string.Concat ("Deleting SubKey ", this.subKey));
					theBoolean = false;
				}
				
			L_0042:
				
				{
				}
				return theBoolean;
			}
			
			public bool DeleteSubKeyTree ()
			
			{
				RegistryKey theRegistryKey;
				RegistryKey theRegistryKey2;
				Exception theException;
				bool theBoolean;
				
			L_0000:
				try
				{
					theRegistryKey = this.baseRegistryKey;
					theRegistryKey2 = theRegistryKey.OpenSubKey (this.subKey);
					if (theRegistryKey2 == null)
					{
						goto L_0023;
					}
					theRegistryKey.DeleteSubKeyTree (this.subKey);
					
				L_0023:
					
					{
					}
					theBoolean = true;
				}
				catch (Exception theException2)
				{
					
				L_0027:
					theException = theException2;
					this.ShowErrorMessage (theException, string.Concat ("Deleting SubKey ", this.subKey));
					theBoolean = false;
				}
				
			L_0043:
				
				{
				}
				return theBoolean;
			}
			
			public string Read (string KeyName)
			
			{
				RegistryKey theRegistryKey;
				RegistryKey theRegistryKey2;
				Exception theException;
				string theString;
				theRegistryKey = this.baseRegistryKey;
				theRegistryKey2 = theRegistryKey.OpenSubKey (this.subKey);
				if (theRegistryKey2 != null)
				{
					goto L_001B;
				}
				theString = ((string) null);
				goto L_004B;
				
			L_001B:
				try
				{
					theString = ((string) theRegistryKey2.GetValue (KeyName.ToUpper ()));
				}
				catch (Exception theException2)
				{
					
				L_002F:
					theException = theException2;
					this.ShowErrorMessage (theException, string.Concat ("Reading registry ", KeyName.ToUpper ()));
					theString = ((string) null);
				}
				
			L_004B:
				
				{
				}
				return theString;
			}
			
			private void ShowErrorMessage (Exception e, string Title)
			
			{
				if (! this.showError)
				{
					goto L_0018;
				}
				DialogResult theDialogResult = MessageBox.Show (e.Message, Title, MessageBoxButtons.OK, MessageBoxIcon.Hand);
				
			L_0018:
				return;
			}
			
			public int SubKeyCount ()
			
			{
				RegistryKey theRegistryKey;
				RegistryKey theRegistryKey2;
				Exception theException;
				int i;
				
			L_0000:
				try
				{
					theRegistryKey = this.baseRegistryKey;
					theRegistryKey2 = theRegistryKey.OpenSubKey (this.subKey);
					if (theRegistryKey2 == null)
					{
						goto L_0020;
					}
					i = theRegistryKey2.SubKeyCount;
					goto L_0040;
					
				L_0020:
					
					{
					}
					i = 0;
				}
				catch (Exception theException2)
				{
					
				L_0024:
					theException = theException2;
					this.ShowErrorMessage (theException, string.Concat ("Retriving subkeys of ", this.subKey));
					i = 0;
				}
				
			L_0040:
				
				{
				}
				return i;
			}
			
			public int ValueCount ()
			
			{
				RegistryKey theRegistryKey;
				RegistryKey theRegistryKey2;
				Exception theException;
				int i;
				
			L_0000:
				try
				{
					theRegistryKey = this.baseRegistryKey;
					theRegistryKey2 = theRegistryKey.OpenSubKey (this.subKey);
					if (theRegistryKey2 == null)
					{
						goto L_0020;
					}
					i = theRegistryKey2.ValueCount;
					goto L_0040;
					
				L_0020:
					
					{
					}
					i = 0;
				}
				catch (Exception theException2)
				{
					
				L_0024:
					theException = theException2;
					this.ShowErrorMessage (theException, string.Concat ("Retriving keys of ", this.subKey));
					i = 0;
				}
				
			L_0040:
				
				{
				}
				return i;
			}
			
			public bool Write (string KeyName, object Value)
			
			{
				RegistryKey theRegistryKey;
				RegistryKey theRegistryKey2;
				Exception theException;
				bool theBoolean;
				
			L_0000:
				try
				{
					theRegistryKey = this.baseRegistryKey;
					theRegistryKey2 = theRegistryKey.CreateSubKey (this.subKey);
					theRegistryKey2.SetValue (KeyName.ToUpper (), Value);
					theBoolean = true;
				}
				catch (Exception theException2)
				{
					
				L_0025:
					theException = theException2;
					this.ShowErrorMessage (theException, string.Concat ("Writing registry ", KeyName.ToUpper ()));
					theBoolean = false;
				}
				
			L_0041:
				
				{
				}
				return theBoolean;
			}
			
		#endregion
	}
	
}

